/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainFunction.java
 *
 * Created on Apr 10, 2012, 12:54:31 PM
 */
package GUI;

import GUI.DoctorManage.AddDoctorForm;
import GUI.DoctorManage.DeleteDoctor;
import GUI.DoctorManage.EditDoctorForm;
import GUI.DoctorManage.ViewDoctorForm;
import GUI.StockManage.AddStockForm;
import GUI.StockManage.DeleteStock;
import GUI.StockManage.EditStockForm;
import GUI.TestManage.ViewTestForm;
import GUI.StockManage.ViewStockForm;
import GUI.TestManage.AddTestForm;
import GUI.TestManage.DeleteTest;
import GUI.TestManage.EditTestForm;
import entities.Admin;
import entities.BillingDetails;
import entities.BillingTestDetail;
import entities.DoctorDetails;
import entities.PatientDetails;
import entities.ReportDetails;
import entities.StaffDetail;
import entities.StockDetail;
import entities.Test;
import entities.TestDetail;
import entities.TestRequireItem;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import model.Bill.TableModelBill;
import model.Bill.TableModelPatient;
import model.report.ReportViewAllTblMdl;
import model.staff.StaffViewAllTblMdl;
import utilities.AllEntitiesManage;
import utilities.BillManage;
import utilities.DateValidate;
import utilities.PatientManage;
import utilities.ReportManage;
import utilities.SimpleDateFormatter;
import utilities.StaffManage;
import utilities.ValidateInput;

/**
 *
 * @author Admin
 */
public class MainFunction extends javax.swing.JFrame {

    private ArrayList<TestDetail> testDetail;
    private ArrayList<ReportDetails> reportList;
    private ArrayList<StockDetail> stockList;
    private ArrayList<Test> testList;
    private ArrayList<PatientDetails> patientList, patientListSearch;
    private ArrayList<DoctorDetails> doctorList;
    private ArrayList<StaffDetail> staffList, staffListSearch;
    private ReportManage rm;
    private OptionMessage optionMessage;
    private ArrayList<TestRequireItem> testRequireItems;
    private DefaultTableModel modelStock;
    private DefaultTableModel modelTest;
    private ArrayList<BillingDetails> billList, billListSearch;
    private ArrayList<BillingTestDetail> billingTestDetails;
    private BillingTestDetail btd;
    private BillManage billManage;
    private PatientManage patientManage;
    private StaffManage staffMan;
    private boolean loginPass = false;
    private StaffDetail currentStaff;
    private DoctorDetails currentDoctor;
    private Admin admin;
    private boolean isRegister = false;
    private int roll = 0;
    private DefaultTableModel modelDoctor;
    private ValidateInput vi = new ValidateInput();
    private DeleteStock ds;
    private DeleteDoctor dd;
    private DeleteTest dt;
    private DateValidate dStart, dEnd;
    private SimpleDateFormatter sdf = new SimpleDateFormatter();
    boolean flag1 = true;
    boolean flag2 = true;
    boolean flag3 = true;

    private void setModelBilling() {
        String[] header = {"Patient Name", "Date", "Amount"};
        TableModelBill tb = new TableModelBill(billList);
        tb.setHeader(header);
        tblBill.setModel(tb);
    }

    private void setModelPatient() {
        String[] header = {"Patient Name", "Address", "Date Of Birth", "Gender"};
        TableModelPatient tmp = new TableModelPatient(patientList);
        tmp.setHeader(header);
        tblPatien.setModel(tmp);
    }

    private void setModelSearchPatient() {
        String[] header = {"Patient Name", "Address", "Date Of Birth", "Gender"};
        TableModelPatient tmp = new TableModelPatient(patientListSearch);
        tmp.setHeader(header);
        tblPatien.setModel(tmp);
    }

    private void setModelSearchStaff() {
        StaffViewAllTblMdl svatm = new StaffViewAllTblMdl(staffListSearch);
        tblStaff.setModel(svatm);
    }

    private void setModelSearchBill() {
        String[] header = {"Patient Name", "Date", "Amount"};
        TableModelBill tb = new TableModelBill(billListSearch);
        tb.setHeader(header);
        tblBill.setModel(tb);
    }

    /** Creates new form MainFunction */
    public MainFunction() {

        optionMessage = new OptionMessage(this);
        AllEntitiesManage ae = new AllEntitiesManage();
        this.admin = ae.getAdmin();
        this.doctorList = new ArrayList<DoctorDetails>();
        this.doctorList = ae.getDoctorList();
        this.reportList = ae.getReportList();
        this.staffList = new ArrayList<StaffDetail>();
        this.staffList = ae.getStaffList();
        this.staffListSearch = new ArrayList<StaffDetail>();
        if (admin == null || doctorList == null || reportList == null || staffList == null) {
            optionMessage.showErrorMessage("Connection problem! Please check your setting!");
            System.exit(0);
        }
        StaffManage sMan = new StaffManage(staffList, this);
        staffMan = new StaffManage(staffList, this);

        while (!isRegister && !loginPass) {
            loginSelect();
            if (!loginPass && isRegister) {
                if (roll == 1) {
                    AddNewStaff addNS = new AddNewStaff(this, true, sMan, this);
                    addNS.setVisible(true);
                } else if (roll == 2) {
                    AddDoctorForm addND = new AddDoctorForm(this, true, doctorList, this);
                    addND.setVisible(true);
                }

                if (!loginPass) {
                    this.roll = 0;
                }
            }
        }
        if (loginPass) {

            try {
                javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(MainFunction.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(MainFunction.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(MainFunction.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(MainFunction.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }





            this.stockList = new ArrayList<StockDetail>();
            this.stockList = ae.getStockList();

            this.testList = new ArrayList<Test>();
            this.testList = ae.getTestList();

            this.patientList = new ArrayList<PatientDetails>();
            this.patientList = ae.getPatientList();



            this.testDetail = new ArrayList<TestDetail>();
            this.testDetail = ae.getTestDetailList();

            this.billList = new ArrayList<BillingDetails>();
            this.billList = ae.getBillList();

            

            this.billManage = new BillManage(billList, testList, this);
            this.patientManage = new PatientManage(patientList, this);

            initComponents();
            setPermission();
            setCurrentUsername();
            this.modelStock = (DefaultTableModel) tblStock.getModel();
            this.modelTest = (DefaultTableModel) tblTest.getModel();
            this.modelDoctor = (DefaultTableModel) tblDoctor.getModel();

            dStart = new DateValidate(cbStartDate, cbStartMonth, cbStartYear);
            dEnd = new DateValidate(cbEndDate, cbEndMonth, cbEndYear);

            rm = new ReportManage(reportList, patientList, testList, doctorList, staffList, this);
            
            setTestData();
            setReportViewData();
            setStockViewData();
            setDoctorViewData();
            setModelBilling();
            setModelPatient();
            setStaffViewData();



        } else {
            System.exit(0);
        }

    }

    private void setPermission() {
        int lSize=reportList.size();
        if (roll == 1 && currentStaff != null) {
//            for (ReportDetails report : reportList) {
//                if (report.getStaffDetail() != null) {
//                    int sID=report.getStaffDetail().getStaffID();
//                    if (((sID) != (currentStaff.getStaffID()))&&((sID) != 0)) {
//                        reportList.remove(report);
//                    }
//                }
//            }

            for (int i=0;i<lSize;i++){
                int sID=reportList.get(i).getStaffDetail().getStaffID();
                    if (((sID) != (currentStaff.getStaffID()))&&((sID) != 0)) {
                        reportList.remove(reportList.get(i));
                        lSize--;
                    }

            }
            jTabbedPane1.remove(4);
            jTabbedPane1.remove(3);
            jTabbedPane1.remove(2);
          //  jTabbedPane1.setDisabledIconAt(4, null);
            jTabbedPane1.remove(1);
            
        } else if (roll == 2 && currentDoctor != null) {
//            for (ReportDetails report : reportList) {
//                if (report.getDoctorDetails() != null) {
//                    if (report.getDoctorDetails().getdID() != currentDoctor.getdID()) {
//                        reportList.remove(report);
//                    }
//                }
//            }
            for (int i=0;i<lSize;i++){
                int sID=reportList.get(i).getDoctorDetails().getdID();
                    if (((sID) != (currentDoctor.getdID()))) {
                        reportList.remove(reportList.get(i));
                        lSize--;
                    }

            }
            jTabbedPane1.remove(4);
            jTabbedPane1.remove(3);
            jTabbedPane1.remove(2);
            jTabbedPane1.remove(1);
            
        }
        btDeletePatient.setVisible(false);
        btDeleteBill.setVisible(false);
        btDeleteReport.setVisible(false);
    }
    private void setCurrentUsername(){
        if(roll==1){
            lblCurrentUsername.setText(currentStaff.getStaffFName());
        }else if(roll==2){
            lblCurrentUsername.setText(currentDoctor.getdFName());
        }else if(roll==3){
            lblCurrentUsername.setText("Admin");
        }
    }
    private void findStaff() {
        staffListSearch = new ArrayList<StaffDetail>();
        boolean flag = true;
        for (int k = 0; k < this.staffList.size(); k++) {
            String name = this.staffList.get(k).getStaffFName() + " " + this.staffList.get(k).getStaffLName();
            int i = 0, j = 0, m, n;
            n = name.length() - 1;
            m = txtSearchStaff.getText().length() - 1;
            do {
                if (name.charAt(i) == txtSearchStaff.getText().charAt(j)) {
                    i++;
                    j++;

                } else {
                    i = i - j + 1;
                    j = 0;

                }

            } while (j <= m && i <= n);
            if (j > m) {

                flag = false;

                staffListSearch.add(this.staffList.get(k));

            }

        }

        if (flag) {
            JOptionPane.showMessageDialog(rootPane, "Not Exist!!!");

        }
        setModelSearchStaff();

    }

    private void findPatient() {
        patientListSearch = new ArrayList<PatientDetails>();
        boolean flag = true;
        for (int k = 0; k < this.patientList.size(); k++) {
            String name = this.patientList.get(k).getpFName() + " " + this.patientList.get(k).getpLName();
            int i = 0, j = 0, m, n;
            n = name.length() - 1;
            m = txtSearchPatient.getText().length() - 1;
            do {
                if (name.charAt(i) == txtSearchPatient.getText().charAt(j)) {
                    i++;
                    j++;

                } else {
                    i = i - j + 1;
                    j = 0;

                }

            } while (j <= m && i <= n);
            if (j > m) {



                flag = false;

                patientListSearch.add(this.patientList.get(k));

            }

        }

        if (flag) {
            JOptionPane.showMessageDialog(rootPane, "Not Exist!!!");
        }
        setModelSearchPatient();


    }
    public boolean isRegistered(){
        return this.isRegister;
    }
    private void addNewBill() {

        AddNewBill anb = new AddNewBill(this, rootPaneCheckingEnabled, billManage, this, null, billList);

        anb.setVisible(true);
    }

    private void updateBill() {

        if (flag2 == false) {

            int i = tblBill.getSelectedRow();
            if (i >= 0 && i < billList.size()) {
                this.billingTestDetails = new ArrayList<BillingTestDetail>();
                this.billingTestDetails = billListSearch.get(i).getBillingTestDetail();
                UpdateBill ud = new UpdateBill(this, true, billListSearch.get(i), billingTestDetails, billManage, this);
                ud.setVisible(true);

                for (int j = 0; j < billList.size(); j++) {
                    if (billList.get(j).getbID() == billListSearch.get(i).getbID()) {
                        billList.set(j, billListSearch.get(i));

                    }
                    flag2 = true;
                }

            } else {
                optionMessage.showMessage("Choose a Bill!!!");
            }

        } else {

            int i = tblBill.getSelectedRow();
            if (i >= 0 && i < billList.size()) {
                this.billingTestDetails = new ArrayList<BillingTestDetail>();
                this.billingTestDetails = billList.get(i).getBillingTestDetail();
                UpdateBill ud = new UpdateBill(this, true, billList.get(i), billingTestDetails, billManage, this);
                ud.setVisible(true);
            } else {
                optionMessage.showMessage("Choose a Bill!!!");
            }
        }
    }

    private void viewBill() {
        if (flag2 == false) {
            int i = tblBill.getSelectedRow();

            if (i >= 0) {
                billingTestDetails = new ArrayList<BillingTestDetail>();
                billingTestDetails = billListSearch.get(i).getBillingTestDetail();

                ViewBill vb = new ViewBill(this, true, billListSearch.get(i), billingTestDetails);
                vb.setVisible(true);
            } else {
                optionMessage.showMessage("Choose a Bill!!!");
            }
        } else {

            int i = tblBill.getSelectedRow();

            if (i >= 0) {
                // billingTestDetails = new ArrayList<BillingTestDetail>();
                billingTestDetails = billList.get(i).getBillingTestDetail();

                ViewBill vb = new ViewBill(this, true, billList.get(i), billingTestDetails);
                vb.setVisible(true);
            } else {
                optionMessage.showMessage("Choose a Bill!!!");
            }

        }


    }

    public void reviewModel() {
        setModelBilling();
        setModelPatient();
    }

    private void viewPatientDetail() {

        if (flag1 == false) {

            int i = tblPatien.getSelectedRow();
            if (i >= 0) {
                ViewPatient vp = new ViewPatient(this, true, patientListSearch.get(i));
                vp.setVisible(true);
            } else {
                optionMessage.showMessage("Choose a Patient!!!");
            }

        } else {

            int i = tblPatien.getSelectedRow();
            if (i >= 0) {
                ViewPatient vp = new ViewPatient(this, true, patientList.get(i));
                vp.setVisible(true);
            } else {
                optionMessage.showMessage("Choose a Patient!!!");
            }
        }
    }

    private void addNewPatient() {

        AddNewPatient anp = new AddNewPatient(this, true, patientManage, billManage, billList);
        anp.setVisible(true);
        setModelBilling();
    }

    private void loadPatient() {

        LoadPatient lp = new LoadPatient(this, true, patientList, patientManage, billManage, billList);
        lp.setVisible(true);
        setModelBilling();
    }

    private void updatePatient() {

        if (flag1 == false) {

            int i = tblPatien.getSelectedRow();
            if (i >= 0) {
                UpdatePatient up = new UpdatePatient(this, true, patientManage, patientListSearch.get(i));
                up.setVisible(true);
                for (int j = 0; j < patientList.size(); j++) {
                    if (patientList.get(j).getpID() == patientListSearch.get(i).getpID()) {
                        patientList.set(j, patientListSearch.get(i));
                    }
                    flag1 = true;
                }

                for (int j = 0; j < billList.size(); j++) {
                    if (billList.get(j).getPatientDetails().getpID() == patientListSearch.get(i).getpID()) {
                        billList.get(j).setPatientDetails(patientListSearch.get(i));
                    }

                }

            } else {
                optionMessage.showMessage("Choose a Patient!!");
            }

        } else {

            int i = tblPatien.getSelectedRow();
            if (i >= 0) {
                UpdatePatient up = new UpdatePatient(this, true, patientManage, patientList.get(i));
                up.setVisible(true);

                for (int j = 0; j < billList.size(); j++) {
                    if (billList.get(j).getPatientDetails().getpID() == patientList.get(i).getpID()) {
                        billList.get(j).setPatientDetails(patientList.get(i));
                    }

                }

            } else {
                optionMessage.showMessage("Choose a Patient!!");
            }
        }
    }

    private void deletePatient() {

        if (flag1 == false) {


            int i = tblPatien.getSelectedRow();

            if (i >= 0) {
                if (optionMessage.confirmDelete("Patient")) {

                    if (patientManage.deletePatient(patientListSearch.get(i))) {
                        int a = patientListSearch.get(i).getpID();
                        patientListSearch.remove(i);
                        for (int j = 0; j < patientList.size(); j++) {
                            if (a == patientList.get(j).getpID()) {
                                patientList.remove(j);
                            }

                        }
                        flag1 = true;
                        for (int j = 0; j < billList.size(); j++) {
                            if (a == billList.get(j).getPatientDetails().getpID()) {
                                billList.remove(j);
                            }

                        }

                        setModelBilling();
                        setModelPatient();

                    }

                }

            } else {
                optionMessage.showMessage("Choose a Patient!!!");
            }


        } else {

            int i = tblPatien.getSelectedRow();

            if (i >= 0) {
                if (optionMessage.confirmDelete("Patient")) {

                    if (patientManage.deletePatient(patientList.get(i))) {
                        int a = patientList.get(i).getpID();
                        patientList.remove(i);
                        for (int j = 0; j < billList.size(); j++) {
                            if (a == billList.get(j).getPatientDetails().getpID()) {
                                billList.remove(j);
                            }

                        }

                        setModelBilling();
                        setModelPatient();

                    }

                }

            } else {
                optionMessage.showMessage("Choose a Patient!!!");
            }
        }
    }

    private void deleteBill() {

        if (flag2 == false) {

            int i = tblBill.getSelectedRow();
            if (i >= 0) {
                if (optionMessage.confirmDelete("Bill")) {

                    if (billManage.deleteBilling(billListSearch.get(i))) {

                        //  billListSearch.remove(i);
                        for (int j = 0; j < billList.size(); j++) {
                            if (billList.get(j).getbID() == billListSearch.get(i).getbID()) {
                                billList.remove(j);
                            }
                        }
                        flag2 = true;
                        setModelBilling();


                    }
                }

            } else {
                optionMessage.showMessage("Choose a Bill!!!");
            }


        } else {



            int i = tblBill.getSelectedRow();
            if (i >= 0) {
                if (optionMessage.confirmDelete("Bill")) {

                    if (billManage.deleteBilling(billList.get(i))) {

                        billList.remove(i);

                        setModelBilling();


                    }
                }

            } else {
                optionMessage.showMessage("Choose a Bill!!!");
            }
        }
    }

    private void searchStockName() {
        for (int i = modelStock.getRowCount() - 1; i >= 0; i--) {
            modelStock.removeRow(i);
        }
        for (StockDetail sd : stockList) {
            Object[] objData = {sd.getsID(), sd.getsName(), sd.getsAvailable(), sd.isIsReuseable()};
            modelStock.addRow(objData);
        }
        String stock = txtSearchStock.getText();
        for (int i = modelStock.getRowCount() - 1; i >= 0; i--) {
            if (modelStock.getValueAt(i, 1).toString().indexOf(stock) < 0) {
                modelStock.removeRow(i);
            }
        }
    }

    private void searchDoctorName() {
        for (int i = modelDoctor.getRowCount() - 1; i >= 0; i--) {
            modelDoctor.removeRow(i);
        }
        for (DoctorDetails dd : doctorList) {
            Object[] objData = {dd.getdID(), dd.getdUsername(), dd.getdFName() + " " + dd.getdLName(), dd.getdAddress(), dd.getdPhone(), dd.getdSpecialization(), dd.isdGender()};
            modelDoctor.addRow(objData);
        }
        String doctorName = txtSearchDoctor.getText();
        for (int i = modelDoctor.getRowCount() - 1; i >= 0; i--) {
            if (modelDoctor.getValueAt(i, 2).toString().indexOf(doctorName) < 0) {
                modelDoctor.removeRow(i);
            }
        }
    }

    private void searchTestName() {
        for (int i = modelTest.getRowCount() - 1; i >= 0; i--) {
            modelTest.removeRow(i);
        }
        for (TestDetail td : testDetail) {
            Object[] objData = {td.getTest().getTestID(), td.getTest().getTestName(), td.getTest().getTestCost()};
            modelTest.addRow(objData);
        }
        String testName = txtSearchTest.getText();
        for (int i = modelTest.getRowCount() - 1; i >= 0; i--) {
            if (modelTest.getValueAt(i, 1).toString().indexOf(testName) < 0) {
                modelTest.removeRow(i);
            }
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        btnEditProfile = new javax.swing.JButton();
        lblCurrentUsername = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtSearchPatient = new javax.swing.JTextField();
        btSearchPatient = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblPatien = new javax.swing.JTable();
        jPanel10 = new javax.swing.JPanel();
        btRefreshPatient = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jPanel11 = new javax.swing.JPanel();
        btViewPatient = new javax.swing.JButton();
        btAddPatient = new javax.swing.JButton();
        btUpdatePatient = new javax.swing.JButton();
        btDeletePatient = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jPanel21 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        txtSearchDoctor = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tblDoctor = new javax.swing.JTable();
        jPanel22 = new javax.swing.JPanel();
        jButton42 = new javax.swing.JButton();
        jButton43 = new javax.swing.JButton();
        jButton44 = new javax.swing.JButton();
        jButton45 = new javax.swing.JButton();
        jButton46 = new javax.swing.JButton();
        jPanel23 = new javax.swing.JPanel();
        btViewDoctor = new javax.swing.JButton();
        btAddDoctor = new javax.swing.JButton();
        btUpdateDoctor = new javax.swing.JButton();
        btDeleteDoctor = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jPanel24 = new javax.swing.JPanel();
        btSearchStaff = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        txtSearchStaff = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        tblStaff = new javax.swing.JTable();
        jPanel25 = new javax.swing.JPanel();
        btRefreshStaff = new javax.swing.JButton();
        jButton53 = new javax.swing.JButton();
        jButton54 = new javax.swing.JButton();
        jButton55 = new javax.swing.JButton();
        jButton56 = new javax.swing.JButton();
        jPanel26 = new javax.swing.JPanel();
        btViewStaff = new javax.swing.JButton();
        btAddStaff = new javax.swing.JButton();
        btUpdateStaff = new javax.swing.JButton();
        btDeleteStaff = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jPanel27 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        txtSearchStock = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        tblStock = new javax.swing.JTable();
        jPanel28 = new javax.swing.JPanel();
        jButton62 = new javax.swing.JButton();
        jButton63 = new javax.swing.JButton();
        jButton64 = new javax.swing.JButton();
        jButton65 = new javax.swing.JButton();
        jButton66 = new javax.swing.JButton();
        jPanel29 = new javax.swing.JPanel();
        btViewStock = new javax.swing.JButton();
        btAddStock = new javax.swing.JButton();
        btUpdateStock = new javax.swing.JButton();
        btDeleteStock = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jPanel12 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        txtSearchTest = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblTest = new javax.swing.JTable();
        jPanel13 = new javax.swing.JPanel();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jButton15 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jPanel14 = new javax.swing.JPanel();
        btViewTest = new javax.swing.JButton();
        btAddTest = new javax.swing.JButton();
        btUpdateTest = new javax.swing.JButton();
        btDeleteTest = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblBill = new javax.swing.JTable();
        jPanel16 = new javax.swing.JPanel();
        btRefreshBill = new javax.swing.JButton();
        jButton23 = new javax.swing.JButton();
        jButton24 = new javax.swing.JButton();
        jButton25 = new javax.swing.JButton();
        jButton26 = new javax.swing.JButton();
        jPanel17 = new javax.swing.JPanel();
        btViewBill = new javax.swing.JButton();
        btAddBill = new javax.swing.JButton();
        btUpdateBill = new javax.swing.JButton();
        btDeleteBill = new javax.swing.JButton();
        jPanel18 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        cbStartDate = new javax.swing.JComboBox();
        cbStartMonth = new javax.swing.JComboBox();
        cbStartYear = new javax.swing.JComboBox();
        cbEndDate = new javax.swing.JComboBox();
        cbEndMonth = new javax.swing.JComboBox();
        cbEndYear = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        btSearchBill = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tblReport = new javax.swing.JTable();
        jPanel19 = new javax.swing.JPanel();
        jButton32 = new javax.swing.JButton();
        jButton33 = new javax.swing.JButton();
        jButton34 = new javax.swing.JButton();
        jButton35 = new javax.swing.JButton();
        jButton36 = new javax.swing.JButton();
        jPanel20 = new javax.swing.JPanel();
        btViewReport = new javax.swing.JButton();
        btAddReport = new javax.swing.JButton();
        btUpdateReport = new javax.swing.JButton();
        btDeleteReport = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(51, 255, 255));

        btnEditProfile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/edit.png"))); // NOI18N
        btnEditProfile.setText("Edit Profile");
        btnEditProfile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditProfileActionPerformed(evt);
            }
        });

        lblCurrentUsername.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblCurrentUsername.setForeground(java.awt.Color.red);
        lblCurrentUsername.setText("Vietlh_11");

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel16.setForeground(java.awt.Color.blue);
        jLabel16.setText("Hi");

        jLabel17.setFont(new java.awt.Font("Tahoma", 3, 20));
        jLabel17.setForeground(java.awt.Color.blue);
        jLabel17.setText("Welcome To Pathology Lab Management System");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addGap(194, 194, 194)
                        .addComponent(jLabel17, javax.swing.GroupLayout.DEFAULT_SIZE, 544, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap(726, Short.MAX_VALUE)
                        .addComponent(jLabel16)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblCurrentUsername)
                .addGap(10, 10, 10)
                .addComponent(btnEditProfile)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel17)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnEditProfile, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblCurrentUsername)
                        .addComponent(jLabel16)))
                .addContainerGap())
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Patient Management Panel", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), new java.awt.Color(0, 153, 51))); // NOI18N

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search Patient", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(51, 0, 255))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel1.setText("Name");

        btSearchPatient.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/businessman_view.png"))); // NOI18N
        btSearchPatient.setText("Search");
        btSearchPatient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSearchPatientActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addComponent(jLabel1)
                .addGap(34, 34, 34)
                .addComponent(txtSearchPatient, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btSearchPatient)
                .addContainerGap(63, Short.MAX_VALUE))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtSearchPatient, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(btSearchPatient))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel2.setForeground(java.awt.Color.red);
        jLabel2.setText("All of Patient");

        tblPatien.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tblPatien);

        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btRefreshPatient.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/refresh.png"))); // NOI18N
        btRefreshPatient.setText("Refresh");
        btRefreshPatient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btRefreshPatientActionPerformed(evt);
            }
        });

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_end.png"))); // NOI18N

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_right_blue.png"))); // NOI18N

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_left_blue.png"))); // NOI18N

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_beginning.png"))); // NOI18N

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                .addComponent(btRefreshPatient)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 557, Short.MAX_VALUE)
                .addComponent(jButton6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addGap(6, 6, 6))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton3)
                .addComponent(jButton4)
                .addComponent(jButton5)
                .addComponent(jButton6)
                .addComponent(btRefreshPatient))
        );

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btViewPatient.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/id_card_information.png"))); // NOI18N
        btViewPatient.setText("View");
        btViewPatient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btViewPatientActionPerformed(evt);
            }
        });

        btAddPatient.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/add2.png"))); // NOI18N
        btAddPatient.setText("Add new");
        btAddPatient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddPatientActionPerformed(evt);
            }
        });

        btUpdatePatient.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/contract.png"))); // NOI18N
        btUpdatePatient.setText("Update");
        btUpdatePatient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUpdatePatientActionPerformed(evt);
            }
        });

        btDeletePatient.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/delete2.png"))); // NOI18N
        btDeletePatient.setText("Delete");
        btDeletePatient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDeletePatientActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(168, 168, 168)
                .addComponent(btViewPatient)
                .addGap(18, 18, 18)
                .addComponent(btAddPatient)
                .addGap(18, 18, 18)
                .addComponent(btUpdatePatient)
                .addGap(18, 18, 18)
                .addComponent(btDeletePatient)
                .addContainerGap(306, Short.MAX_VALUE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btViewPatient)
                    .addComponent(btAddPatient)
                    .addComponent(btUpdatePatient)
                    .addComponent(btDeletePatient))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 880, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(145, 145, 145)
                        .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(29, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Patient ", new javax.swing.ImageIcon(getClass().getResource("/images/Ico/Patient-32.png")), jPanel2); // NOI18N

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Doctor Managemet Panel", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), new java.awt.Color(0, 153, 51))); // NOI18N

        jPanel21.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search Doctor", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(51, 0, 255))); // NOI18N

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel3.setText("Name");

        txtSearchDoctor.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtSearchDoctorKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtSearchDoctorKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21);
        jPanel21.setLayout(jPanel21Layout);
        jPanel21Layout.setHorizontalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addComponent(jLabel3)
                .addGap(34, 34, 34)
                .addComponent(txtSearchDoctor, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(166, Short.MAX_VALUE))
        );
        jPanel21Layout.setVerticalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtSearchDoctor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel7.setForeground(java.awt.Color.red);
        jLabel7.setText("All of Doctor");

        tblDoctor.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Doctor ID", "User Name", "FullName", "Address", "Phone", "Specialization", "Gender"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane5.setViewportView(tblDoctor);

        jPanel22.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jButton42.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/refresh.png"))); // NOI18N
        jButton42.setText("Refresh");

        jButton43.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_end.png"))); // NOI18N

        jButton44.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_right_blue.png"))); // NOI18N

        jButton45.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_left_blue.png"))); // NOI18N

        jButton46.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_beginning.png"))); // NOI18N

        javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
        jPanel22.setLayout(jPanel22Layout);
        jPanel22Layout.setHorizontalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel22Layout.createSequentialGroup()
                .addComponent(jButton42)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 557, Short.MAX_VALUE)
                .addComponent(jButton46)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton45)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton44)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton43)
                .addGap(6, 6, 6))
        );
        jPanel22Layout.setVerticalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton43)
                .addComponent(jButton44)
                .addComponent(jButton45)
                .addComponent(jButton46)
                .addComponent(jButton42))
        );

        jPanel23.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btViewDoctor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/id_card_information.png"))); // NOI18N
        btViewDoctor.setText("View");
        btViewDoctor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btViewDoctorActionPerformed(evt);
            }
        });

        btAddDoctor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/add2.png"))); // NOI18N
        btAddDoctor.setText("Add new");
        btAddDoctor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddDoctorActionPerformed(evt);
            }
        });

        btUpdateDoctor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/contract.png"))); // NOI18N
        btUpdateDoctor.setText("Update");
        btUpdateDoctor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUpdateDoctorActionPerformed(evt);
            }
        });

        btDeleteDoctor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/delete2.png"))); // NOI18N
        btDeleteDoctor.setText("Delete");
        btDeleteDoctor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDeleteDoctorActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel23Layout = new javax.swing.GroupLayout(jPanel23);
        jPanel23.setLayout(jPanel23Layout);
        jPanel23Layout.setHorizontalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addGap(168, 168, 168)
                .addComponent(btViewDoctor)
                .addGap(18, 18, 18)
                .addComponent(btAddDoctor)
                .addGap(18, 18, 18)
                .addComponent(btUpdateDoctor)
                .addGap(18, 18, 18)
                .addComponent(btDeleteDoctor)
                .addContainerGap(306, Short.MAX_VALUE))
        );
        jPanel23Layout.setVerticalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btViewDoctor)
                    .addComponent(btAddDoctor)
                    .addComponent(btUpdateDoctor)
                    .addComponent(btDeleteDoctor))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(135, 135, 135)
                        .addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel7))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 880, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(31, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Doctor ", new javax.swing.ImageIcon(getClass().getResource("/images/Ico/Doctor-32.png")), jPanel3); // NOI18N

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Staff Management Panel", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), new java.awt.Color(0, 153, 51))); // NOI18N

        jPanel24.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search Staff", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(51, 0, 255))); // NOI18N

        btSearchStaff.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/businessman_view.png"))); // NOI18N
        btSearchStaff.setText("Search");
        btSearchStaff.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSearchStaffActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel10.setText("Name");

        javax.swing.GroupLayout jPanel24Layout = new javax.swing.GroupLayout(jPanel24);
        jPanel24.setLayout(jPanel24Layout);
        jPanel24Layout.setHorizontalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel24Layout.createSequentialGroup()
                .addContainerGap(66, Short.MAX_VALUE)
                .addComponent(jLabel10)
                .addGap(34, 34, 34)
                .addComponent(txtSearchStaff, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(31, 31, 31)
                .addComponent(btSearchStaff)
                .addGap(28, 28, 28))
        );
        jPanel24Layout.setVerticalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel24Layout.createSequentialGroup()
                .addGroup(jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btSearchStaff)
                    .addComponent(txtSearchStaff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel8.setForeground(java.awt.Color.red);
        jLabel8.setText("All of Staff");

        tblStaff.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane6.setViewportView(tblStaff);

        jPanel25.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btRefreshStaff.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/refresh.png"))); // NOI18N
        btRefreshStaff.setText("Refresh");
        btRefreshStaff.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btRefreshStaffActionPerformed(evt);
            }
        });

        jButton53.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_end.png"))); // NOI18N

        jButton54.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_right_blue.png"))); // NOI18N

        jButton55.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_left_blue.png"))); // NOI18N

        jButton56.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_beginning.png"))); // NOI18N

        javax.swing.GroupLayout jPanel25Layout = new javax.swing.GroupLayout(jPanel25);
        jPanel25.setLayout(jPanel25Layout);
        jPanel25Layout.setHorizontalGroup(
            jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel25Layout.createSequentialGroup()
                .addComponent(btRefreshStaff)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 557, Short.MAX_VALUE)
                .addComponent(jButton56)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton55)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton54)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton53)
                .addGap(6, 6, 6))
        );
        jPanel25Layout.setVerticalGroup(
            jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton53)
                .addComponent(jButton54)
                .addComponent(jButton55)
                .addComponent(jButton56)
                .addComponent(btRefreshStaff))
        );

        jPanel26.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btViewStaff.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/id_card_information.png"))); // NOI18N
        btViewStaff.setText("View");
        btViewStaff.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btViewStaffActionPerformed(evt);
            }
        });

        btAddStaff.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/add2.png"))); // NOI18N
        btAddStaff.setText("Add new");
        btAddStaff.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddStaffActionPerformed(evt);
            }
        });

        btUpdateStaff.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/contract.png"))); // NOI18N
        btUpdateStaff.setText("Update");
        btUpdateStaff.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUpdateStaffActionPerformed(evt);
            }
        });

        btDeleteStaff.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/delete2.png"))); // NOI18N
        btDeleteStaff.setText("Delete");
        btDeleteStaff.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDeleteStaffActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel26Layout = new javax.swing.GroupLayout(jPanel26);
        jPanel26.setLayout(jPanel26Layout);
        jPanel26Layout.setHorizontalGroup(
            jPanel26Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel26Layout.createSequentialGroup()
                .addGap(168, 168, 168)
                .addComponent(btViewStaff)
                .addGap(18, 18, 18)
                .addComponent(btAddStaff)
                .addGap(18, 18, 18)
                .addComponent(btUpdateStaff)
                .addGap(18, 18, 18)
                .addComponent(btDeleteStaff)
                .addContainerGap(306, Short.MAX_VALUE))
        );
        jPanel26Layout.setVerticalGroup(
            jPanel26Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel26Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel26Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btViewStaff)
                    .addComponent(btAddStaff)
                    .addComponent(btUpdateStaff)
                    .addComponent(btDeleteStaff))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(129, 129, 129)
                        .addComponent(jPanel24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel8))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 880, Short.MAX_VALUE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel25, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel26, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jPanel24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel25, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel26, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(26, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Staff ", new javax.swing.ImageIcon(getClass().getResource("/images/Ico/Staff-32.png")), jPanel4); // NOI18N

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Stock Management Panel", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), new java.awt.Color(0, 153, 51))); // NOI18N

        jPanel27.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search Stock", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(51, 0, 255))); // NOI18N

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel11.setText("Name");

        txtSearchStock.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtSearchStockKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtSearchStockKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel27Layout = new javax.swing.GroupLayout(jPanel27);
        jPanel27.setLayout(jPanel27Layout);
        jPanel27Layout.setHorizontalGroup(
            jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel27Layout.createSequentialGroup()
                .addContainerGap(60, Short.MAX_VALUE)
                .addComponent(jLabel11)
                .addGap(34, 34, 34)
                .addComponent(txtSearchStock, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(150, 150, 150))
        );
        jPanel27Layout.setVerticalGroup(
            jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel27Layout.createSequentialGroup()
                .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtSearchStock, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel9.setForeground(java.awt.Color.red);
        jLabel9.setText("All of Stock");

        tblStock.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Stock ID", "Stock Name", "Available", "Reseable"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane7.setViewportView(tblStock);

        jPanel28.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jButton62.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/refresh.png"))); // NOI18N
        jButton62.setText("Refresh");
        jButton62.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton62ActionPerformed(evt);
            }
        });

        jButton63.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_end.png"))); // NOI18N

        jButton64.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_right_blue.png"))); // NOI18N

        jButton65.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_left_blue.png"))); // NOI18N

        jButton66.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_beginning.png"))); // NOI18N

        javax.swing.GroupLayout jPanel28Layout = new javax.swing.GroupLayout(jPanel28);
        jPanel28.setLayout(jPanel28Layout);
        jPanel28Layout.setHorizontalGroup(
            jPanel28Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel28Layout.createSequentialGroup()
                .addComponent(jButton62)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 557, Short.MAX_VALUE)
                .addComponent(jButton66)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton65)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton64)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton63)
                .addGap(6, 6, 6))
        );
        jPanel28Layout.setVerticalGroup(
            jPanel28Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel28Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton63)
                .addComponent(jButton64)
                .addComponent(jButton65)
                .addComponent(jButton66)
                .addComponent(jButton62))
        );

        jPanel29.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btViewStock.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/id_card_information.png"))); // NOI18N
        btViewStock.setText("View");
        btViewStock.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btViewStockActionPerformed(evt);
            }
        });

        btAddStock.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/add2.png"))); // NOI18N
        btAddStock.setText("Add new");
        btAddStock.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddStockActionPerformed(evt);
            }
        });

        btUpdateStock.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/contract.png"))); // NOI18N
        btUpdateStock.setText("Update");
        btUpdateStock.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUpdateStockActionPerformed(evt);
            }
        });

        btDeleteStock.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/delete2.png"))); // NOI18N
        btDeleteStock.setText("Delete");
        btDeleteStock.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDeleteStockActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel29Layout = new javax.swing.GroupLayout(jPanel29);
        jPanel29.setLayout(jPanel29Layout);
        jPanel29Layout.setHorizontalGroup(
            jPanel29Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel29Layout.createSequentialGroup()
                .addGap(168, 168, 168)
                .addComponent(btViewStock)
                .addGap(18, 18, 18)
                .addComponent(btAddStock)
                .addGap(18, 18, 18)
                .addComponent(btUpdateStock)
                .addGap(18, 18, 18)
                .addComponent(btDeleteStock)
                .addContainerGap(306, Short.MAX_VALUE))
        );
        jPanel29Layout.setVerticalGroup(
            jPanel29Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel29Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel29Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btViewStock)
                    .addComponent(btAddStock)
                    .addComponent(btUpdateStock)
                    .addComponent(btDeleteStock))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(136, 136, 136)
                        .addComponent(jPanel27, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel9))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 880, Short.MAX_VALUE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel28, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel29, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jPanel27, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel28, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel29, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(31, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Stock ", new javax.swing.ImageIcon(getClass().getResource("/images/Ico/Stock-32.png")), jPanel5); // NOI18N

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Test Management Panel", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), new java.awt.Color(0, 153, 51))); // NOI18N

        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search Test", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(51, 0, 255))); // NOI18N

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel12.setText("Name");

        txtSearchTest.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtSearchTestKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtSearchTestKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                .addContainerGap(67, Short.MAX_VALUE)
                .addComponent(jLabel12)
                .addGap(34, 34, 34)
                .addComponent(txtSearchTest, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(143, 143, 143))
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtSearchTest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel4.setForeground(java.awt.Color.red);
        jLabel4.setText("All of Test");

        tblTest.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Test ID", "Test Name", "Test Cost"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Float.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane2.setViewportView(tblTest);

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jButton12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/refresh.png"))); // NOI18N
        jButton12.setText("Refresh");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jButton13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_end.png"))); // NOI18N

        jButton14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_right_blue.png"))); // NOI18N

        jButton15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_left_blue.png"))); // NOI18N

        jButton16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_beginning.png"))); // NOI18N

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
                .addComponent(jButton12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 557, Short.MAX_VALUE)
                .addComponent(jButton16)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton15)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton13)
                .addGap(6, 6, 6))
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton13)
                .addComponent(jButton14)
                .addComponent(jButton15)
                .addComponent(jButton16)
                .addComponent(jButton12))
        );

        jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btViewTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/id_card_information.png"))); // NOI18N
        btViewTest.setText("View");
        btViewTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btViewTestActionPerformed(evt);
            }
        });

        btAddTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/add2.png"))); // NOI18N
        btAddTest.setText("Add new");
        btAddTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddTestActionPerformed(evt);
            }
        });

        btUpdateTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/contract.png"))); // NOI18N
        btUpdateTest.setText("Update");
        btUpdateTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUpdateTestActionPerformed(evt);
            }
        });

        btDeleteTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/delete2.png"))); // NOI18N
        btDeleteTest.setText("Delete");
        btDeleteTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDeleteTestActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addGap(168, 168, 168)
                .addComponent(btViewTest)
                .addGap(18, 18, 18)
                .addComponent(btAddTest)
                .addGap(18, 18, 18)
                .addComponent(btUpdateTest)
                .addGap(18, 18, 18)
                .addComponent(btDeleteTest)
                .addContainerGap(306, Short.MAX_VALUE))
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btViewTest)
                    .addComponent(btAddTest)
                    .addComponent(btUpdateTest)
                    .addComponent(btDeleteTest))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel4))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 880, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(126, 126, 126)
                        .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(31, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Test ", new javax.swing.ImageIcon(getClass().getResource("/images/Ico/Test-32.png")), jPanel6); // NOI18N

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Billing Management Panel", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), new java.awt.Color(0, 153, 51))); // NOI18N

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel5.setForeground(java.awt.Color.red);
        jLabel5.setText("All of Billing");

        tblBill.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane3.setViewportView(tblBill);

        jPanel16.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btRefreshBill.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/refresh.png"))); // NOI18N
        btRefreshBill.setText("Refresh");
        btRefreshBill.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btRefreshBillActionPerformed(evt);
            }
        });

        jButton23.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_end.png"))); // NOI18N

        jButton24.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_right_blue.png"))); // NOI18N

        jButton25.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_left_blue.png"))); // NOI18N

        jButton26.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_beginning.png"))); // NOI18N

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel16Layout.createSequentialGroup()
                .addComponent(btRefreshBill)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 557, Short.MAX_VALUE)
                .addComponent(jButton26)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton25)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton24)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton23)
                .addGap(6, 6, 6))
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton23)
                .addComponent(jButton24)
                .addComponent(jButton25)
                .addComponent(jButton26)
                .addComponent(btRefreshBill))
        );

        jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btViewBill.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/id_card_information.png"))); // NOI18N
        btViewBill.setText("View");
        btViewBill.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btViewBillActionPerformed(evt);
            }
        });

        btAddBill.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/add2.png"))); // NOI18N
        btAddBill.setText("Add new");
        btAddBill.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddBillActionPerformed(evt);
            }
        });

        btUpdateBill.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/contract.png"))); // NOI18N
        btUpdateBill.setText("Update");
        btUpdateBill.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUpdateBillActionPerformed(evt);
            }
        });

        btDeleteBill.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/delete2.png"))); // NOI18N
        btDeleteBill.setText("Delete");
        btDeleteBill.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDeleteBillActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
        jPanel17.setLayout(jPanel17Layout);
        jPanel17Layout.setHorizontalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addGap(168, 168, 168)
                .addComponent(btViewBill)
                .addGap(18, 18, 18)
                .addComponent(btAddBill)
                .addGap(18, 18, 18)
                .addComponent(btUpdateBill)
                .addGap(18, 18, 18)
                .addComponent(btDeleteBill)
                .addContainerGap(306, Short.MAX_VALUE))
        );
        jPanel17Layout.setVerticalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btViewBill)
                    .addComponent(btAddBill)
                    .addComponent(btUpdateBill)
                    .addComponent(btDeleteBill))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel18.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search Bill", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(51, 0, 255))); // NOI18N

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel14.setText("From");

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel15.setText("To");

        btSearchBill.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/businessman_view.png"))); // NOI18N
        btSearchBill.setText("Search");
        btSearchBill.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSearchBillActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
        jPanel18.setLayout(jPanel18Layout);
        jPanel18Layout.setHorizontalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addGap(50, 50, 50)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cbStartDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbStartMonth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbStartYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(8, 8, 8)
                .addComponent(jLabel15)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cbEndDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbEndMonth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbEndYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btSearchBill)
                .addContainerGap(27, Short.MAX_VALUE))
        );
        jPanel18Layout.setVerticalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(cbStartDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbStartMonth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbStartYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbEndDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbEndMonth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbEndYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15)
                    .addComponent(btSearchBill))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 880, Short.MAX_VALUE)
                            .addComponent(jPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(132, 132, 132)
                        .addComponent(jPanel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Billing ", new javax.swing.ImageIcon(getClass().getResource("/images/Ico/Billing-32.png")), jPanel7); // NOI18N

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Report Management Panel", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), new java.awt.Color(0, 153, 51))); // NOI18N

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel6.setForeground(java.awt.Color.red);
        jLabel6.setText("All of Report");

        tblReport.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane4.setViewportView(tblReport);

        jPanel19.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jButton32.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/refresh.png"))); // NOI18N
        jButton32.setText("Refresh");
        jButton32.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton32ActionPerformed(evt);
            }
        });

        jButton33.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_end.png"))); // NOI18N

        jButton34.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_right_blue.png"))); // NOI18N

        jButton35.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/arrow_left_blue.png"))); // NOI18N

        jButton36.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/media_beginning.png"))); // NOI18N

        javax.swing.GroupLayout jPanel19Layout = new javax.swing.GroupLayout(jPanel19);
        jPanel19.setLayout(jPanel19Layout);
        jPanel19Layout.setHorizontalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel19Layout.createSequentialGroup()
                .addComponent(jButton32)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 557, Short.MAX_VALUE)
                .addComponent(jButton36)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton35)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton34)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton33)
                .addGap(6, 6, 6))
        );
        jPanel19Layout.setVerticalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton33)
                .addComponent(jButton34)
                .addComponent(jButton35)
                .addComponent(jButton36)
                .addComponent(jButton32))
        );

        jPanel20.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btViewReport.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/id_card_information.png"))); // NOI18N
        btViewReport.setText("View");
        btViewReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btViewReportActionPerformed(evt);
            }
        });

        btAddReport.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/add2.png"))); // NOI18N
        btAddReport.setText("Add new");
        btAddReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddReportActionPerformed(evt);
            }
        });

        btUpdateReport.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/contract.png"))); // NOI18N
        btUpdateReport.setText("Update");
        btUpdateReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUpdateReportActionPerformed(evt);
            }
        });

        btDeleteReport.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Icons/delete2.png"))); // NOI18N
        btDeleteReport.setText("Delete");
        btDeleteReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDeleteReportActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel20Layout = new javax.swing.GroupLayout(jPanel20);
        jPanel20.setLayout(jPanel20Layout);
        jPanel20Layout.setHorizontalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel20Layout.createSequentialGroup()
                .addGap(168, 168, 168)
                .addComponent(btViewReport)
                .addGap(18, 18, 18)
                .addComponent(btAddReport)
                .addGap(18, 18, 18)
                .addComponent(btUpdateReport)
                .addGap(18, 18, 18)
                .addComponent(btDeleteReport)
                .addContainerGap(306, Short.MAX_VALUE))
        );
        jPanel20Layout.setVerticalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel20Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btViewReport)
                    .addComponent(btAddReport)
                    .addComponent(btUpdateReport)
                    .addComponent(btDeleteReport))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 880, Short.MAX_VALUE)
                    .addComponent(jPanel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(92, 92, 92)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Report ", new javax.swing.ImageIcon(getClass().getResource("/images/Ico/Report-32.png")), jPanel8); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 917, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 467, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btDeletePatientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDeletePatientActionPerformed
        deletePatient();
    }//GEN-LAST:event_btDeletePatientActionPerformed

    private void btDeleteTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDeleteTestActionPerformed
        if (tblTest.getSelectedRow() >= 0) {
            int r = Integer.parseInt(modelTest.getValueAt(tblTest.getSelectedRow(), 0).toString());
            dt = new DeleteTest(testDetail, getByIDTest(r), this);
            dt.deleteTest();
        } else {
            JOptionPane.showMessageDialog(rootPane, "Youmust select a row Data!!!");
        }
    }//GEN-LAST:event_btDeleteTestActionPerformed

    private void btAddTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddTestActionPerformed

        AddTestForm atf = new AddTestForm(this, true, testDetail, stockList, this);
        atf.setVisible(true);
    }//GEN-LAST:event_btAddTestActionPerformed

    private void btAddBillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddBillActionPerformed
        loadPatient();
    }//GEN-LAST:event_btAddBillActionPerformed

    private void btDeleteBillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDeleteBillActionPerformed
        deleteBill();
    }//GEN-LAST:event_btDeleteBillActionPerformed

    private void btAddReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddReportActionPerformed
        // TODO add your handling code here:
        addNewReport();
    }//GEN-LAST:event_btAddReportActionPerformed

    private void btDeleteReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDeleteReportActionPerformed
        deleteReportDetail();
    }//GEN-LAST:event_btDeleteReportActionPerformed

    private void btDeleteDoctorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDeleteDoctorActionPerformed
        if (tblDoctor.getSelectedRow() >= 0) {
            int r = Integer.parseInt(modelDoctor.getValueAt(tblDoctor.getSelectedRow(), 0).toString());
            dd = new DeleteDoctor(doctorList, getByIDDoctoc(r), this);
            dd.deleteDoctor();
        } else {
            JOptionPane.showMessageDialog(rootPane, "You must select a row Data!!!");
        }
    }//GEN-LAST:event_btDeleteDoctorActionPerformed

    private void btDeleteStaffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDeleteStaffActionPerformed
        deleteStaffDetail();
    }//GEN-LAST:event_btDeleteStaffActionPerformed

    private void btDeleteStockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDeleteStockActionPerformed
        if (tblStock.getSelectedRow() >= 0) {
            int r = Integer.parseInt(modelStock.getValueAt(tblStock.getSelectedRow(), 0).toString());
            ds = new DeleteStock(stockList, getByIDStock(r), this);
            ds.deleteStock();
        } else {
            JOptionPane.showMessageDialog(rootPane, "You must select a row Data!!!");
        }

    }//GEN-LAST:event_btDeleteStockActionPerformed

    private void btViewReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btViewReportActionPerformed

        viewReportDetail();
    }//GEN-LAST:event_btViewReportActionPerformed

    private void btUpdateReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUpdateReportActionPerformed
        // TODO add your handling code here:
        updateReportDetail();
    }//GEN-LAST:event_btUpdateReportActionPerformed

    private void jButton32ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton32ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton32ActionPerformed

    private void btUpdateTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUpdateTestActionPerformed
        if (tblTest.getSelectedRow() >= 0) {
            int r = Integer.parseInt(modelTest.getValueAt(tblTest.getSelectedRow(), 0).toString());
            testRequireItems = getByIDTest(r).getTestRequireItemList();
            EditTestForm etf = new EditTestForm(this, true, testDetail, getByIDTest(r), testRequireItems, stockList, this);
            etf.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(rootPane, "You must select a row Data!!!");
        }
    }//GEN-LAST:event_btUpdateTestActionPerformed

    private void btViewTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btViewTestActionPerformed
        if (tblTest.getSelectedRow() >= 0) {
            int r = Integer.parseInt(modelTest.getValueAt(tblTest.getSelectedRow(), 0).toString());
            testRequireItems = getByIDTest(r).getTestRequireItemList();
            ViewTestForm vtf = new ViewTestForm(this, true, getByIDTest(r), testRequireItems, this);
            vtf.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(rootPane, "You must select a row Data!!!");
        }
    }//GEN-LAST:event_btViewTestActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        // TODO add your handling code here:        
    }//GEN-LAST:event_jButton12ActionPerformed

    private void btViewStockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btViewStockActionPerformed
        // TODO add your handling code here:
        if (tblStock.getSelectedRow() >= 0) {
            int r = Integer.parseInt(modelStock.getValueAt(tblStock.getSelectedRow(), 0).toString());
            ViewStockForm viewStockForm = new ViewStockForm(this, true, getByIDStock(r));
            viewStockForm.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(rootPane, "You must select a row data!!!");
        }

    }//GEN-LAST:event_btViewStockActionPerformed

    private void btAddStockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddStockActionPerformed
        // TODO add your handling code here:
        AddStockForm asf = new AddStockForm(this, true, stockList, this);
        asf.setVisible(true);
    }//GEN-LAST:event_btAddStockActionPerformed

    private void btUpdateStockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUpdateStockActionPerformed
        if (tblStock.getSelectedRow() >= 0) {
            int r = Integer.parseInt(modelStock.getValueAt(tblStock.getSelectedRow(), 0).toString());
            EditStockForm esf = new EditStockForm(this, true, stockList, getByIDStock(r), this);
            esf.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(rootPane, "You must select a row data!!!");
        }
    }//GEN-LAST:event_btUpdateStockActionPerformed

    private void btViewDoctorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btViewDoctorActionPerformed
        if (tblDoctor.getSelectedRow() >= 0) {
            int r = Integer.parseInt(modelDoctor.getValueAt(tblDoctor.getSelectedRow(), 0).toString());
            ViewDoctorForm vdf = new ViewDoctorForm(this, true, getByIDDoctoc(r));
            vdf.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(rootPane, "You must select a row Data!!!");
        }
    }//GEN-LAST:event_btViewDoctorActionPerformed

    private void btAddDoctorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddDoctorActionPerformed

        AddDoctorForm adf = new AddDoctorForm(this, true, doctorList, this);
        adf.setVisible(true);
    }//GEN-LAST:event_btAddDoctorActionPerformed

    private void btUpdateDoctorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUpdateDoctorActionPerformed
        if (tblDoctor.getSelectedRow() >= 0) {
            int r = Integer.parseInt(modelDoctor.getValueAt(tblDoctor.getSelectedRow(), 0).toString());
            EditDoctorForm edf = new EditDoctorForm(this, true, doctorList, getByIDDoctoc(r), this);
            edf.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(rootPane, "You must select a row Data!!!");
        }
    }//GEN-LAST:event_btUpdateDoctorActionPerformed

    private void jButton62ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton62ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton62ActionPerformed

    private void btViewBillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btViewBillActionPerformed
        viewBill();
    }//GEN-LAST:event_btViewBillActionPerformed

    private void btUpdateBillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUpdateBillActionPerformed
        updateBill();
    }//GEN-LAST:event_btUpdateBillActionPerformed

    private void btViewPatientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btViewPatientActionPerformed
        viewPatientDetail();
    }//GEN-LAST:event_btViewPatientActionPerformed

    private void btAddPatientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddPatientActionPerformed
        addNewPatient();
    }//GEN-LAST:event_btAddPatientActionPerformed

    private void btUpdatePatientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUpdatePatientActionPerformed
        updatePatient();

    }//GEN-LAST:event_btUpdatePatientActionPerformed

    private void btViewStaffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btViewStaffActionPerformed
        viewStaffDetail();
    }//GEN-LAST:event_btViewStaffActionPerformed

    private void btAddStaffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddStaffActionPerformed
        addNewStaff();
    }//GEN-LAST:event_btAddStaffActionPerformed

    private void btUpdateStaffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUpdateStaffActionPerformed
        updateStaffDetail();
    }//GEN-LAST:event_btUpdateStaffActionPerformed

    private void txtSearchDoctorKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtSearchDoctorKeyPressed
        searchDoctorName();
    }//GEN-LAST:event_txtSearchDoctorKeyPressed

    private void txtSearchDoctorKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtSearchDoctorKeyReleased
        searchDoctorName();
    }//GEN-LAST:event_txtSearchDoctorKeyReleased

    private void txtSearchStockKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtSearchStockKeyPressed
        searchStockName();
    }//GEN-LAST:event_txtSearchStockKeyPressed

    private void txtSearchStockKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtSearchStockKeyReleased
        searchStockName();
    }//GEN-LAST:event_txtSearchStockKeyReleased

    private void txtSearchTestKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtSearchTestKeyPressed
        searchTestName();
    }//GEN-LAST:event_txtSearchTestKeyPressed

    private void txtSearchTestKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtSearchTestKeyReleased
        searchTestName();
    }//GEN-LAST:event_txtSearchTestKeyReleased

    private void btSearchPatientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSearchPatientActionPerformed
        if (vi.checkIsEmpty(txtSearchPatient.getText())) {
            JOptionPane.showMessageDialog(rootPane, "Input a Patient!!!");
            return;
        } else {
            findPatient();
            flag1 = false;
        }
    }//GEN-LAST:event_btSearchPatientActionPerformed

    private void btRefreshPatientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRefreshPatientActionPerformed
        flag1 = true;
        setModelPatient();
    }//GEN-LAST:event_btRefreshPatientActionPerformed

    private void btRefreshStaffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRefreshStaffActionPerformed
        flag3 = true;
        setStaffViewData();
    }//GEN-LAST:event_btRefreshStaffActionPerformed

    private void btSearchStaffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSearchStaffActionPerformed
        if (vi.checkIsEmpty(txtSearchStaff.getText())) {
            JOptionPane.showMessageDialog(rootPane, "Input a Staff!!!");
            return;
        } else {
            findStaff();
            flag3 = false;
        }
    }//GEN-LAST:event_btSearchStaffActionPerformed

    private void btSearchBillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSearchBillActionPerformed
        billListSearch = new ArrayList<BillingDetails>();

        String start = (cbStartMonth.getSelectedIndex() + 1) + "/" + (cbStartDate.getSelectedIndex() + 1) + "/" + (cbStartYear.getSelectedIndex() + 1900);
        String end = (cbEndMonth.getSelectedIndex() + 1) + "/" + (cbEndDate.getSelectedIndex() + 1) + "/" + (cbEndYear.getSelectedIndex() + 1900);


        billListSearch = billManage.searchBill(sdf.convertStringToDate(start), sdf.convertStringToDate(end), billList);
        flag2 = false;
        setModelSearchBill();

    }//GEN-LAST:event_btSearchBillActionPerformed

    private void btRefreshBillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRefreshBillActionPerformed
        flag2 = true;
        setModelBilling();

    }//GEN-LAST:event_btRefreshBillActionPerformed

    private void btnEditProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditProfileActionPerformed
        // TODO add your handling code here:
        if(roll==1){
            EditStaff es=new EditStaff(this, true, staffMan, this, currentStaff);
//            es.setVisible(true);
        }else if(roll==2){
            EditDoctorForm edf=new EditDoctorForm(this, true, doctorList, currentDoctor, this);
            edf.setVisible(true);
        }else if(roll==3){
            EditAdminPassword eap=new EditAdminPassword(this,true,admin);
            eap.setVisible(true);
        }
    }//GEN-LAST:event_btnEditProfileActionPerformed

    private void setTestData() {
        for (int i = modelTest.getRowCount() - 1; i >= 0; i--) {
            modelTest.removeRow(i);
        }
        for (TestDetail td : testDetail) {
            Object[] objData = {td.getTest().getTestID(), td.getTest().getTestName(), td.getTest().getTestCost()};
            modelTest.addRow(objData);
        }
    }

    private void setStockViewData() {
        for (int i = modelStock.getRowCount() - 1; i >= 0; i--) {
            modelStock.removeRow(i);
        }
        for (StockDetail sd : stockList) {
            String reseable = "";
            if (sd.isIsReuseable()) {
                reseable = "Yes";
            } else {
                reseable = "No";
            }
            Object[] objData = {sd.getsID(), sd.getsName(), sd.getsAvailable(), reseable};
            modelStock.addRow(objData);
        }
    }

    private void setDoctorViewData() {
        for (int i = modelDoctor.getRowCount() - 1; i >= 0; i--) {
            modelDoctor.removeRow(i);
        }
        for (DoctorDetails details : doctorList) {
            String gender = "";
            if (details.isdGender()) {
                gender = "Male";
            } else {
                gender = "Female";
            }
            Object[] objData = {details.getdID(), details.getdUsername(), details.getdFName() + " " + details.getdLName(), details.getdAddress(), details.getdPhone(), details.getdSpecialization(), gender};
            modelDoctor.addRow(objData);
        }
    }

    private void deleteReportDetail() {
        int index = tblReport.getSelectedRow();
        if (index >= 0 && index < reportList.size()) {
            ReportDetails reportDetail = new ReportDetails();
            reportDetail = reportList.get(index);

            if (rm.deleteReport(reportDetail)) {
            }



        } else {
            optionMessage.showMessage("Please select a report first!");
        }
    }

    private void deleteStaffDetail() {
        if (flag3 == false) {
            int i = tblStaff.getSelectedRow();

            if (i >= 0) {
                staffMan.deleteStaff(staffListSearch.get(tblStaff.getSelectedRow()));
                for (int j = 0; j < staffList.size(); j++) {
                    if (staffList.get(j).getStaffID() == staffListSearch.get(i).getStaffID()) {
                        staffList.remove(j);
                    }

                }

                flag3 = true;
                setStaffViewData();
            } else {
                optionMessage.showMessage("Choose a Staff!!!");
            }
        } else {

            int i = tblStaff.getSelectedRow();

            if (i >= 0) {
                staffMan.deleteStaff(staffList.get(tblStaff.getSelectedRow()));
            } else {
                optionMessage.showMessage("Choose a Staff!!!");
            }

        }



    }

    private void setStaffViewData() {
        StaffViewAllTblMdl svModel = new StaffViewAllTblMdl(staffList);
        tblStaff.setModel(svModel);
    }

    private void setReportViewData() {
        ReportViewAllTblMdl rvModel = new ReportViewAllTblMdl(reportList);
        tblReport.setModel(rvModel);
    }

    private void viewStaffDetail() {

        if (flag3 == false) {
            int i = tblStaff.getSelectedRow();
            if (i >= 0) {
                staffMan.viewStaffDetail(staffListSearch.get(tblStaff.getSelectedRow()));
            } else {
                optionMessage.showMessage("Choose a Staff!!!");
            }

        } else {

            int i = tblStaff.getSelectedRow();
            if (i >= 0) {
                staffMan.viewStaffDetail(staffList.get(tblStaff.getSelectedRow()));
            } else {
                optionMessage.showMessage("Choose a Staff!!!");
            }
        }


    }

    private void addNewStaff() {
        AddNewStaff ansf = new AddNewStaff(this, true, staffMan, this);
        ansf.setVisible(true);
    }

    private void updateStaffDetail() {

        if (flag3 == false) {
            int index = tblStaff.getSelectedRow();
            if (index >= 0 && index < staffListSearch.size()) {

                EditStaff es = new EditStaff(this, loginPass, staffMan, this, staffListSearch.get(index));
                for (int i = 0; i < staffList.size(); i++) {
                    if (staffList.get(i).getStaffID() == staffListSearch.get(index).getStaffID()) {
                        staffList.set(i, staffListSearch.get(index));

                    }
                    flag3 = true;
                }

            } else {
                optionMessage.showMessage("Please select a staff first!");
            }
        } else {

            int index = tblStaff.getSelectedRow();
            if (index >= 0 && index < staffList.size()) {

                EditStaff es = new EditStaff(this, loginPass, staffMan, this, staffList.get(index));
            } else {
                optionMessage.showMessage("Please select a staff first!");
            }
        }
    }

    private void addNewReport() {
        AddNewReportForm anrf = new AddNewReportForm(this, true, testList, patientList, rm, this);
        anrf.setVisible(true);
    }

    private void viewReportDetail() {
        int index = tblReport.getSelectedRow();
        if (index >= 0 && index < reportList.size()) {
            ReportDetails reportDetail = new ReportDetails();
            reportDetail = reportList.get(index);
            ViewReportForm vrf = new ViewReportForm(this, rootPaneCheckingEnabled, reportDetail);
        } else {
            optionMessage.showMessage("Please select a report first!");
        }
    }

    private void updateReportDetail() {
        int index = tblReport.getSelectedRow();
        if (index >= 0 && index < reportList.size()) {
            ReportDetails reportDetail = new ReportDetails();
            reportDetail = reportList.get(index);
            EditReportForm erf = new EditReportForm(this, true, reportDetail, doctorList, staffList, testList, patientList, rm);
        } else {
            optionMessage.showMessage("Please select a report first!");
        }
    }

    public void refreshReportTableView() {
        if (tblBill != null && tblDoctor != null && tblPatien != null && tblReport != null && tblStaff != null && tblStock != null && tblTest != null) {
            {


                setReportViewData();
                setStaffViewData();
                setTestData();
                setStockViewData();
                setDoctorViewData();
            }

        }
    }
    private void loginSelect() {
        LoginSelectType lst = new LoginSelectType(this, true, this, doctorList, staffList, admin);
        lst.setVisible(true);
    }

    public void setLoginPass(boolean loginPass) {
        this.loginPass = loginPass;
    }

    public boolean isLoginPass() {
        return this.loginPass;
    }

    public void setRegister(boolean isRegister) {
        this.isRegister = isRegister;
    }

    public void setRoll(int roll) {
        this.roll = roll;
    }

    public void setCurrentUser(Object currentUser) {
        if (currentUser instanceof DoctorDetails) {
            this.currentDoctor = new DoctorDetails();
            this.currentDoctor = (DoctorDetails) currentUser;
        } else if (currentUser instanceof StaffDetail) {
            this.currentStaff = new StaffDetail();
            this.currentStaff = (StaffDetail) currentUser;
        } else if (currentUser instanceof Admin) {
            this.admin = new Admin();
            this.admin = (Admin) currentUser;
        }
    }
    public ArrayList<ReportDetails> getReportList(){
        return reportList;
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new MainFunction().setVisible(true);
            }
        });
    }

    private StockDetail getByIDStock(int r) {
        for (StockDetail sd : stockList) {
            if (r == sd.getsID()) {
                return sd;
            }
        }
        return null;
    }

    private DoctorDetails getByIDDoctoc(int r) {
        for (DoctorDetails dds : doctorList) {
            if (r == dds.getdID()) {
                return dds;
            }
        }
        return null;
    }

    private TestDetail getByIDTest(int r) {
        for (TestDetail td : testDetail) {
            if (r == td.getTest().getTestID()) {
                return td;
            }
        }
        return null;
    }
//    public void setTests(ArrayList<TestDetail> TestDetail) {
//        this.testDetail = new ArrayList<TestDetail>();
//
//        this.testDetail = TestDetail;
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btAddBill;
    private javax.swing.JButton btAddDoctor;
    private javax.swing.JButton btAddPatient;
    private javax.swing.JButton btAddReport;
    private javax.swing.JButton btAddStaff;
    private javax.swing.JButton btAddStock;
    private javax.swing.JButton btAddTest;
    private javax.swing.JButton btDeleteBill;
    private javax.swing.JButton btDeleteDoctor;
    private javax.swing.JButton btDeletePatient;
    private javax.swing.JButton btDeleteReport;
    private javax.swing.JButton btDeleteStaff;
    private javax.swing.JButton btDeleteStock;
    private javax.swing.JButton btDeleteTest;
    private javax.swing.JButton btRefreshBill;
    private javax.swing.JButton btRefreshPatient;
    private javax.swing.JButton btRefreshStaff;
    private javax.swing.JButton btSearchBill;
    private javax.swing.JButton btSearchPatient;
    private javax.swing.JButton btSearchStaff;
    private javax.swing.JButton btUpdateBill;
    private javax.swing.JButton btUpdateDoctor;
    private javax.swing.JButton btUpdatePatient;
    private javax.swing.JButton btUpdateReport;
    private javax.swing.JButton btUpdateStaff;
    private javax.swing.JButton btUpdateStock;
    private javax.swing.JButton btUpdateTest;
    private javax.swing.JButton btViewBill;
    private javax.swing.JButton btViewDoctor;
    private javax.swing.JButton btViewPatient;
    private javax.swing.JButton btViewReport;
    private javax.swing.JButton btViewStaff;
    private javax.swing.JButton btViewStock;
    private javax.swing.JButton btViewTest;
    private javax.swing.JButton btnEditProfile;
    private javax.swing.JComboBox cbEndDate;
    private javax.swing.JComboBox cbEndMonth;
    private javax.swing.JComboBox cbEndYear;
    private javax.swing.JComboBox cbStartDate;
    private javax.swing.JComboBox cbStartMonth;
    private javax.swing.JComboBox cbStartYear;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton23;
    private javax.swing.JButton jButton24;
    private javax.swing.JButton jButton25;
    private javax.swing.JButton jButton26;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton32;
    private javax.swing.JButton jButton33;
    private javax.swing.JButton jButton34;
    private javax.swing.JButton jButton35;
    private javax.swing.JButton jButton36;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton42;
    private javax.swing.JButton jButton43;
    private javax.swing.JButton jButton44;
    private javax.swing.JButton jButton45;
    private javax.swing.JButton jButton46;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton53;
    private javax.swing.JButton jButton54;
    private javax.swing.JButton jButton55;
    private javax.swing.JButton jButton56;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton62;
    private javax.swing.JButton jButton63;
    private javax.swing.JButton jButton64;
    private javax.swing.JButton jButton65;
    private javax.swing.JButton jButton66;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel19;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel20;
    private javax.swing.JPanel jPanel21;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JPanel jPanel23;
    private javax.swing.JPanel jPanel24;
    private javax.swing.JPanel jPanel25;
    private javax.swing.JPanel jPanel26;
    private javax.swing.JPanel jPanel27;
    private javax.swing.JPanel jPanel28;
    private javax.swing.JPanel jPanel29;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lblCurrentUsername;
    private javax.swing.JTable tblBill;
    private javax.swing.JTable tblDoctor;
    private javax.swing.JTable tblPatien;
    private javax.swing.JTable tblReport;
    private javax.swing.JTable tblStaff;
    private javax.swing.JTable tblStock;
    private javax.swing.JTable tblTest;
    private javax.swing.JTextField txtSearchDoctor;
    private javax.swing.JTextField txtSearchPatient;
    private javax.swing.JTextField txtSearchStaff;
    private javax.swing.JTextField txtSearchStock;
    private javax.swing.JTextField txtSearchTest;
    // End of variables declaration//GEN-END:variables
}
